﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity.ModelConfiguration;
using MyBlog.DataEntity;

namespace MyBlog.DataAccess
{
    internal class AccountMap : EntityTypeConfiguration<Tbl_Account>
    {
        public AccountMap()
        {
            this.Property(e => e.Education)
                 .IsFixedLength()
                 .IsUnicode(false);

            this.HasMany(e => e.Tbl_Album)
                 .WithRequired(e => e.Tbl_Account)
                 .HasForeignKey(e => e.AccountId)
                 .WillCascadeOnDelete(false);

            this.HasMany(e => e.Tbl_Article)
                 .WithRequired(e => e.Tbl_Account)
                 .HasForeignKey(e => e.AccountId)
                 .WillCascadeOnDelete(false);

            this.HasMany(e => e.Tbl_Category)
                 .WithRequired(e => e.Tbl_Account)
                 .HasForeignKey(e => e.AccountId)
                 .WillCascadeOnDelete(false);

            this.HasMany(e => e.Tbl_Tag)
                .WithRequired(e => e.Tbl_Account)
                .HasForeignKey(e => e.AccountId)
                .WillCascadeOnDelete(false);

            this.HasMany(e => e.Tbl_Message)
                 .WithOptional(e => e.Tbl_Account)
                 .HasForeignKey(e => e.AccountId)
                 .WillCascadeOnDelete(false);

            this.HasMany(e => e.Tbl_Mood)
                 .WithRequired(e => e.Tbl_Account)
                 .HasForeignKey(e => e.AccountId)
                 .WillCascadeOnDelete(false);

            this.HasMany(e => e.MyConcernUsers)
              .WithRequired(e => e.Account)
              .HasForeignKey(e => e.UID)
              .WillCascadeOnDelete(false);

            this.HasMany(e => e.ConcernMeUsers)
              .WithRequired(e => e.ConcernUser)
              .HasForeignKey(e => e.ConcernUID)
              .WillCascadeOnDelete(false);

            this.HasMany(e => e.MyNotices)
              .WithRequired(e => e.Account)
              .HasForeignKey(e => e.NoticeUID)
              .WillCascadeOnDelete(false);

        }
    }
}
